var t = require;
var e = module;
var o = exports;
var i, n = this && this.__extends || (i = function(t, e) {
    return (i = Object.setPrototypeOf || {
        __proto__: []
    }
    instanceof Array &&
    function(t, e) {
        t.__proto__ = e
    } ||
    function(t, e) {
        for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o])
    })(t, e)
},
function(t, e) {
    function o() {
        this.constructor = t
    }
    i(t, e),
    t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o)
}),
a = this && this.__decorate ||
function(t, e, o, i) {
    var n, a = arguments.length,
    r = a < 3 ? e: null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, i);
    else for (var s = t.length - 1; s >= 0; s--)(n = t[s]) && (r = (a < 3 ? n(r) : a > 3 ? n(e, o, r) : n(e, o)) || r);
    return a > 3 && r && Object.defineProperty(e, o, r),
    r
};
Object.defineProperty(o, "__esModule", {
    value: !0
});
var r = t("GameConstant"),
s = t("CarConstant"),
l = t("GameLogic"),
c = t("WheelItemManage"),
d = t("WheelAloneItemManage"),
h = t("CarRoleView"),
p = t("Util"),
u = t("GlobalUserData"),
f = t("Global"),
m = cc._decorator,
_ = m.ccclass,
y = m.property,
g = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.pfb_role = null,
        e.pfb_wheel = null,
        e.pfb_wheelAlone = null,
        e.nodeBody_left = null,
        e.nodeBody_right = null,
        e._gameControl = null,
        e._gameLogic = new l.GameLogic,
        e._strBodyId = null,
        e._carBodyData = null,
        e.wheel0Control = null,
        e.wheel1Control = null,
        e.roleControl = null,
        e.nCurOrient = r.Car_Orientation.Default,
        e.nCurMoveOrient = r.Car_Orientation.Default,
        e._carTag = 0,
        e.arrDisassItem = [],
        e.bLinearing = !1,
        e.nCurAIMoveTime = 0,
        e.bAIStart = !1,
        e.bPreAiMoveTime = 0,
        e.intervalTime = .1,
        e
    }
    return n(e, t),
    e.prototype.init = function(t, e, o, i, n, a) {
        var l;
        switch (this._gameControl = t, this._strBodyId = i, cc.log("车身index:" + this._strBodyId), this._carTag = e, this.nodeBody_left.active = e == r.Physics_Car_Tag.Left, this.nodeBody_right.active = e == r.Physics_Car_Tag.Right, this.nodeBody_left.getComponent(cc.RigidBody).type = cc.RigidBodyType.Static, this.nodeBody_right.getComponent(cc.RigidBody).type = cc.RigidBodyType.Static, u.default.nCurGameType == r.Game_Type.PK ? (this.nodeBody_left.scale = r.Game_Type_Scale.PK, this.nodeBody_right.scale = r.Game_Type_Scale.PK) : u.default.nCurGameType == r.Game_Type.PK_1 ? (this.nodeBody_left.scale = r.Game_Type_Scale.PK_1, this.nodeBody_right.scale = r.Game_Type_Scale.PK_1, o = cc.v3(o.x, o.y + 200, o.z)) : u.default.nCurGameType == r.Game_Type.PK_2 ? (this.nodeBody_left.scale = r.Game_Type_Scale.PK_2, this.nodeBody_right.scale = r.Game_Type_Scale.PK_2, o = cc.v3(o.x, o.y, o.z)) : (this.nodeBody_left.scale = 1, this.nodeBody_right.scale = 1), l = null != a && a == f.Quality.epic, e) {
            case r.Physics_Car_Tag.Left:
                this.setCarCurOrient(r.Car_Orientation.Right),
            l && p.Util.setBodyParts(this.nodeBody_left.getChildByName("body"), u.default.pbf_partsArr[s.getBodyData(this.getBodyId()).index]),
            this.createRole(this.nodeBody_left, i, r.Physics_Car_Tag.Left),
            this.setCarPosAndScale(this.nodeBody_left, o),
            this.nodeBody_left.getChildByName("body").zIndex = 20,
            this.createLeftWheel(n, i),
            this.nodeBody_left.getComponent(cc.PhysicsPolygonCollider).tag = this._gameLogic.getPhysicsTag(r.Physics_Car_Tag.Left, r.Physics_Body_Tag.Car);
            break;
            case r.Physics_Car_Tag.Right:
                this.setCarCurOrient(r.Car_Orientation.Left),
            l && p.Util.setBodyParts(this.nodeBody_right.getChildByName("body"), u.default.pbf_partsArr[s.getBodyData(this.getBodyId()).index]),
            this.createRole(this.nodeBody_right, i, r.Physics_Car_Tag.Right),
            this.setCarPosAndScale(this.nodeBody_right, o),
            this.nodeBody_right.getChildByName("body").zIndex = 20,
            this.createRightWheel(n, i),
            this.nodeBody_right.getComponent(cc.PhysicsPolygonCollider).tag = this._gameLogic.getPhysicsTag(r.Physics_Car_Tag.Right, r.Physics_Body_Tag.Car);
        }
        this._carBodyData = s.GetCarBodyData(this._strBodyId)
    },
    e.prototype.initOverView = function(t, e, o, i) {
        switch (this._strBodyId = o, this._carTag = t, this.nodeBody_left.active = t == r.Physics_Car_Tag.Left, this.nodeBody_right.active = t == r.Physics_Car_Tag.Right, this.nodeBody_left.getComponent(cc.RigidBody).type = cc.RigidBodyType.Static, this.nodeBody_right.getComponent(cc.RigidBody).type = cc.RigidBodyType.Static, u.default.nCurGameType == r.Game_Type.PK ? (this.nodeBody_left.scale = r.Game_Type_Scale.PK, this.nodeBody_right.scale = r.Game_Type_Scale.PK) : u.default.nCurGameType == r.Game_Type.PK_1 ? (this.nodeBody_left.scale = r.Game_Type_Scale.PK_1, this.nodeBody_right.scale = r.Game_Type_Scale.PK_1, e = cc.v3(0, e.y, e.z)) : u.default.nCurGameType == r.Game_Type.PK_2 ? (this.nodeBody_left.scale = r.Game_Type_Scale.PK_2, this.nodeBody_right.scale = r.Game_Type_Scale.PK_2) : (this.nodeBody_left.scale = 1, this.nodeBody_right.scale = 1), t) {
            case r.Physics_Car_Tag.Left:
                this.setCarCurOrient(r.Car_Orientation.Right),
            this.createRole(this.nodeBody_left, o, r.Physics_Car_Tag.Left),
            this.setCarPosAndScale(this.nodeBody_left, e),
            this.nodeBody_left.getChildByName("body").zIndex = 20,
            this.createLeftWheel(i, o),
            this.nodeBody_left.getComponent(cc.PhysicsPolygonCollider).tag = this._gameLogic.getPhysicsTag(r.Physics_Car_Tag.Left, r.Physics_Body_Tag.Car);
            break;
            case r.Physics_Car_Tag.Right:
                this.setCarCurOrient(r.Car_Orientation.Left),
            this.createRole(this.nodeBody_right, o, r.Physics_Car_Tag.Right),
            this.setCarPosAndScale(this.nodeBody_right, e),
            this.nodeBody_right.getChildByName("body").zIndex = 20,
            this.createRightWheel(i, o),
            this.nodeBody_right.getComponent(cc.PhysicsPolygonCollider).tag = this._gameLogic.getPhysicsTag(r.Physics_Car_Tag.Right, r.Physics_Body_Tag.Car);
        }
        this._carBodyData = s.GetCarBodyData(this._strBodyId)
    },
    e.prototype.setCarPosAndScale = function(t, e) {
        r.Cur_Game_Type == r.Game_Type.PK ? (t.position = cc.v3(e.x, e.y + r.Game_PK_Car_PosY, e.z), t.scale = r.Game_Type_Scale.PK, this.nodeBody_right.getComponent(cc.PhysicsPolygonCollider).density = r.Game_Type_Scale.PK * this.nodeBody_right.getComponent(cc.PhysicsPolygonCollider).density) : (t.position = e, t.scale = r.Game_Type_Scale.Auto)
    },
    e.prototype.getBodyId = function() {
        return this._strBodyId
    },
    e.prototype.getRigidBody = function() {
        return this._carTag == r.Physics_Car_Tag.Left ? this.nodeBody_left.getComponent(cc.RigidBody) : this.nodeBody_right.getComponent(cc.RigidBody)
    },
    e.prototype.getCarPos = function() {
        return this._carTag == r.Physics_Car_Tag.Left ? this.nodeBody_left.position: this.nodeBody_right.position
    },
    e.prototype.getCarBodyWidth = function() {
        var t = 1;
        return u.default.nCurGameType == r.Game_Type.PK ? t = r.Game_Type_Scale.PK: u.default.nCurGameType == r.Game_Type.PK_1 ? t = r.Game_Type_Scale.PK_1: u.default.nCurGameType == r.Game_Type.PK_2 && (t = r.Game_Type_Scale.PK_2),
        this._carTag == r.Physics_Car_Tag.Left ? this.nodeBody_left.getChildByName("body").width * t: this.nodeBody_right.getChildByName("body").width * t
    },
    e.prototype.getCarWorldPos = function() {
        return this._carTag == r.Physics_Car_Tag.Left ? this.nodeBody_left.convertToWorldSpaceAR(cc.Vec2.ZERO) : this.nodeBody_right.convertToWorldSpaceAR(cc.Vec2.ZERO)
    },
    e.prototype.getCarToWorldPos = function(t) {
        return this._carTag == r.Physics_Car_Tag.Left ? this.nodeBody_left.convertToWorldSpaceAR(t) : this.nodeBody_right.convertToWorldSpaceAR(t)
    },
    e.prototype.getCarToNodedPos = function(t) {
        return this._carTag == r.Physics_Car_Tag.Left ? this.nodeBody_left.convertToNodeSpaceAR(t) : this.nodeBody_right.convertToNodeSpaceAR(t)
    },
    e.prototype.getCarRotation = function() {
        return this._carTag == r.Physics_Car_Tag.Left ? this.nodeBody_left.angle: this.nodeBody_right.angle
    },
    e.prototype.getAngle = function() {
        return this._carTag == r.Physics_Car_Tag.Left ? this.nodeBody_left.angle: this.nodeBody_right.angle
    },
    e.prototype.getScaleX = function() {
        return this._carTag == r.Physics_Car_Tag.Left ? this.nodeBody_left.scaleX: this.nodeBody_right.scaleX
    },
    e.prototype.getCurOrient = function() {
        return this.nCurOrient
    },
    e.prototype.setCarCurOrient = function(t) {
        this.nCurOrient = t
    },
    e.prototype.setCurMoveOrient = function(t) {
        this.nCurMoveOrient = t,
        this.nCurAIMoveTime = 0,
        this.bPreAiMoveTime = 0,
        this.intervalTime = .5,
        this.bAIStart = !1
    },
    e.prototype.onGameStart = function() {
        this.nodeBody_left.getComponent(cc.RigidBody).type = cc.RigidBodyType.Dynamic,
        this.nodeBody_right.getComponent(cc.RigidBody).type = cc.RigidBodyType.Dynamic,
        this.wheel0Control && this.wheel0Control.onGameStart(),
        this.wheel1Control && this.wheel1Control.onGameStart()
    },
    e.prototype.onGameOver = function() {
        this.wheel0Control && this.wheel0Control.onGameOver(),
        this.wheel1Control && this.wheel1Control.onGameOver(),
        this.node.active = !1;
        for (var t = 0; t < this.arrDisassItem.length; t++) this.arrDisassItem[t].destroy();
        this.arrDisassItem.length = 0,
        this.destroy()
    },
    e.prototype.onGameWin = function() {},
    e.prototype.onGameFail = function() {
        this.node.active = !1
    },
    e.prototype.onGameBoutReady = function() {
        this.roleControl.playAniOut(),
        this.nodeBody_left.angle = 0,
        this.nodeBody_right.angle = 0,
        this.node.active = !1,
        this.nodeBody_left.getComponent(cc.RigidBody).type = cc.RigidBodyType.Static,
        this.nodeBody_right.getComponent(cc.RigidBody).type = cc.RigidBodyType.Static;
        for (var t = 0; t < this.arrDisassItem.length; t++) {
            var e = this.arrDisassItem[t];
            e && e.destroy()
        }
        this.arrDisassItem.length = 0,
        this.destroy()
    },
    e.prototype.onGameBoutStart = function() {
        this.node.active = !0,
        this.roleControl.playAniOut(),
        this.nodeBody_left.getComponent(cc.RigidBody).type = cc.RigidBodyType.Dynamic,
        this.nodeBody_right.getComponent(cc.RigidBody).type = cc.RigidBodyType.Dynamic,
        this.wheel0Control && this.wheel0Control.onGameStart(),
        this.wheel1Control && this.wheel1Control.onGameStart()
    },
    e.prototype.onGameBoutOver = function() {
        this.wheel0Control && this.wheel0Control.onGameBoutOver(),
        this.wheel1Control && this.wheel1Control.onGameBoutOver()
    },
    e.prototype.onGameBoutWin = function() {
        this.roleControl.playAniWin()
    },
    e.prototype.onGameBoutFail = function() {
        this.node.active = !1
    },
    e.prototype.createLeftWheel = function(t, e) {
        var o = s.GetCarBodyData(e);
        if (t[0]) {
            var i = p.Util.getWheelData(t[0]),
            n = s.getWheelData(i.id);
            this.wheel0Control || (this.wheel0Control = this.createWheelItem(this.nodeBody_left)),
            this.wheel0Control.init(n.index, i, this.nodeBody_left.getComponent(cc.RigidBody), r.Physics_Car_Tag.Left, this._gameLogic.getPhysicsTag(r.Physics_Car_Tag.Left, r.Physics_Body_Tag.Wheel0), o.wheelPos[0])
        }
        t[1] && (i = p.Util.getWheelData(t[1]), n = s.getWheelData(i.id), this.wheel1Control || (this.wheel1Control = this.createWheelItem(this.nodeBody_left)), this.wheel1Control.init(n.index, i, this.nodeBody_left.getComponent(cc.RigidBody), r.Physics_Car_Tag.Left, this._gameLogic.getPhysicsTag(r.Physics_Car_Tag.Left, r.Physics_Body_Tag.Wheel1), o.wheelPos[1]))
    },
    e.prototype.createRightWheel = function(t, e) {
        var o = s.GetCarBodyData(e);
        if (t[0]) {
            var i = s.getWheelData(t[0].id);
            this.wheel0Control || (this.wheel0Control = this.createWheelItem(this.nodeBody_right)),
            this.wheel0Control.init(i.index, t[0], this.nodeBody_right.getComponent(cc.RigidBody), r.Physics_Car_Tag.Right, this._gameLogic.getPhysicsTag(r.Physics_Car_Tag.Right, r.Physics_Body_Tag.Wheel0), o.wheelPos[0])
        }
        t[1] && (i = s.getWheelData(t[1].id), this.wheel1Control || (this.wheel1Control = this.createWheelItem(this.nodeBody_right)), this.wheel1Control.init(i.index, t[1], this.nodeBody_right.getComponent(cc.RigidBody), r.Physics_Car_Tag.Right, this._gameLogic.getPhysicsTag(r.Physics_Car_Tag.Right, r.Physics_Body_Tag.Wheel1), o.wheelPos[1]))
    },
    e.prototype.createWheelItem = function(t) {
        var e = cc.instantiate(this.pfb_wheel);
        return t.addChild(e),
        e.zIndex = 30,
        e.getComponent(c.default)
    },
    e.prototype.createRole = function(t, e, o) {
        if (!this.roleControl) {
            var i = cc.instantiate(this.pfb_role);
            t.addChild(i),
            i.zIndex = 10,
            this.roleControl = i.getComponent(h.default)
        }
        this.roleControl.init(this, o, e),
        this.roleControl.playAniIn()
    },
    e.prototype.playHammerEffect = function(t, e) {
        var o = s.GetCarWeaponData(e).impulse;
        if (this._carTag == r.Physics_Car_Tag.Left) {
            var i = this.nodeBody_left.convertToWorldSpaceAR(cc.Vec2.ZERO),
            n = p.Util.GetPointAngle(t, i) / 180 * Math.PI,
            a = 0,
            l = 0;
            a = o.x * Math.cos(n),
            l = o.x * Math.sin(n),
            this.nodeBody_left.getComponent(cc.RigidBody).applyLinearImpulse(cc.v2( - a, l), i, !0)
        } else i = this.nodeBody_right.convertToWorldSpaceAR(cc.Vec2.ZERO),
        n = p.Util.GetPointAngle(t, i) / 180 * Math.PI,
        a = 0,
        l = 0,
        a = o.x * Math.cos(n),
        l = o.x * Math.sin(n),
        this.nodeBody_right.getComponent(cc.RigidBody).applyLinearImpulse(cc.v2(a, -l), i, !0)
    },
    e.prototype.mineBlowOff = function(t) {
        var e = s.GetCarToolsData(s.Tools_ID.Landmine).impulse;
        if (this._carTag == r.Physics_Car_Tag.Left) {
            var o = this.nodeBody_left.convertToWorldSpaceAR(cc.Vec2.ZERO),
            i = p.Util.GetPointAngle(t, o) / 180 * Math.PI,
            n = 0,
            a = 0;
            n = e.x * Math.cos(i),
            a = e.x * Math.sin(i),
            this.nodeBody_left.getComponent(cc.RigidBody).applyLinearImpulse(cc.v2( - n, a), o, !0)
        } else o = this.nodeBody_right.convertToWorldSpaceAR(cc.Vec2.ZERO),
        i = p.Util.GetPointAngle(t, o) / 180 * Math.PI,
        n = 0,
        a = 0,
        n = e.x * Math.cos(i),
        a = e.x * Math.sin(i),
        this.nodeBody_right.getComponent(cc.RigidBody).applyLinearImpulse(cc.v2(n, -a), o, !0)
    },
    e.prototype.bombImpulse = function(t) {
        var e = cc.v2(this.nodeBody_right.position.x, this.nodeBody_right.position.y).sub(t).normalize(),
        o = 5e3 * e.x,
        i = 5e3 * e.y;
        this.nodeBody_right.getComponent(cc.RigidBody).linearVelocity = cc.v2(o, i)
    },
    e.prototype.playRevThruster = function() {
        var t, e = s.GetCarToolsData(s.Tools_ID.RevThruster).impulse,
        o = this.getAngle() / 180 * Math.PI,
        i = 0;
        if (i = e.x * Math.cos(o), t = e.x * Math.sin(o), this._carTag == r.Physics_Car_Tag.Left) {
            var n = this.nodeBody_left.convertToWorldSpaceAR(cc.Vec2.ZERO);
            this.nodeBody_left.scaleX < 0 && (i = -i),
            this.nodeBody_left.getComponent(cc.RigidBody).applyLinearImpulse(cc.v2( - i, t), n, !0)
        } else n = this.nodeBody_right.convertToWorldSpaceAR(cc.Vec2.ZERO),
        this.nodeBody_right.scaleX < 0 && (i = -i),
        this.nodeBody_right.getComponent(cc.RigidBody).applyLinearImpulse(cc.v2(i, -t), n, !0)
    },
    e.prototype.playThruster = function() {
        var t, e = s.GetCarToolsData(s.Tools_ID.Thruster).impulse,
        o = this.getAngle() / 180 * Math.PI,
        i = 0;
        if (i = e.x * Math.cos(o), t = e.x * Math.sin(o), this._carTag == r.Physics_Car_Tag.Left) {
            var n = this.nodeBody_left.convertToWorldSpaceAR(cc.Vec2.ZERO);
            this.nodeBody_left.scaleX < 0 && (i = -i),
            this.nodeBody_left.getComponent(cc.RigidBody).applyLinearImpulse(cc.v2(i, t), n, !0)
        } else n = this.nodeBody_right.convertToWorldSpaceAR(cc.Vec2.ZERO),
        this.nodeBody_right.scaleX < 0 && (i = -i),
        this.nodeBody_right.getComponent(cc.RigidBody).applyLinearImpulse(cc.v2( - i, t), n, !0)
    },
    e.prototype.onDisassembly = function(t) {
        if (this._carTag == r.Physics_Car_Tag.Left) {
            if (1 == t) {
                if (this.wheel1Control) {
                    this.wheel1Control.onDisassembly();
                    var e = this.createWheelAloneItem(this._gameControl.node),
                    o = this.wheel1Control.getPos(),
                    i = this._gameControl.node.convertToNodeSpaceAR(o);
                    e.init(this.wheel1Control.getIndex(), r.Physics_Car_Tag.Left, 0, cc.v3(i.x, i.y, i.z))
                }
            } else 2 == t && this.wheel0Control && (this.wheel0Control.onDisassembly(), e = this.createWheelAloneItem(this._gameControl.node), o = this.wheel0Control.getPos(), i = this._gameControl.node.convertToNodeSpaceAR(o), e.init(this.wheel0Control.getIndex(), r.Physics_Car_Tag.Left, 0, cc.v3(i.x, i.y, i.z)));
        } else 1 == t ? this.wheel1Control && (this.wheel1Control.onDisassembly(), e = this.createWheelAloneItem(this._gameControl.node), o = this.wheel1Control.getPos(), i = this._gameControl.node.convertToNodeSpaceAR(o), e.init(this.wheel1Control.getIndex(), r.Physics_Car_Tag.Right, 0, cc.v3( - i.x, i.y, i.z))) : 2 == t && this.wheel0Control && (this.wheel0Control.onDisassembly(), e = this.createWheelAloneItem(this._gameControl.node), o = this.wheel0Control.getPos(), i = this._gameControl.node.convertToNodeSpaceAR(o), e.init(this.wheel0Control.getIndex(), r.Physics_Car_Tag.Right, 0, cc.v3( - i.x, i.y, i.z)))
    },
    e.prototype.createWheelAloneItem = function(t) {
        var e = cc.instantiate(this.pfb_wheelAlone);
        return t.addChild(e),
        e.zIndex = 50,
        this.arrDisassItem.push(e),
        e.getComponent(d.default)
    },
    e.prototype.onMoveLeft = function(t, e) {
        this.setCurMoveOrient(r.Car_Orientation.Left),
        this.wheel0Control && this.wheel0Control.onMoveLeft(e),
        this.wheel1Control && this.wheel1Control.onMoveLeft(e),
        e && this.onRollingOver(r.Car_Orientation.Left),
        this._carTag == r.Physics_Car_Tag.Left ? (this.nodeBody_left.getComponent(cc.RigidBody).angularDamping = this._carBodyData.angularDamping, this.nodeBody_left.getComponent(cc.RigidBody).angularVelocity = this._carBodyData.angularVelocity, this.nodeBody_left.getComponent(cc.RigidBody).linearDamping = this._carBodyData.linearDamping, this.nodeBody_left.getComponent(cc.RigidBody).linearVelocity = cc.v2( - this._carBodyData.linearVelocity.x, this._carBodyData.linearVelocity.y)) : (this.nodeBody_right.getComponent(cc.RigidBody).angularDamping = this._carBodyData.angularDamping, this.nodeBody_right.getComponent(cc.RigidBody).angularVelocity = this._carBodyData.angularVelocity, this.nodeBody_right.getComponent(cc.RigidBody).linearDamping = this._carBodyData.linearDamping, this.nodeBody_right.getComponent(cc.RigidBody).linearVelocity = cc.v2( - this._carBodyData.linearVelocity.x, this._carBodyData.linearVelocity.y))
    },
    e.prototype.onMoveRight = function(t, e) {
        this.setCurMoveOrient(r.Car_Orientation.Right),
        this.wheel0Control && this.wheel0Control.onMoveRight(e),
        this.wheel1Control && this.wheel1Control.onMoveRight(e),
        e && this.onRollingOver(r.Car_Orientation.Right),
        this._carTag == r.Physics_Car_Tag.Left ? (this.nodeBody_left.getComponent(cc.RigidBody).angularDamping = this._carBodyData.angularDamping, this.nodeBody_left.getComponent(cc.RigidBody).angularVelocity = -this._carBodyData.angularVelocity, this.nodeBody_left.getComponent(cc.RigidBody).linearDamping = this._carBodyData.linearDamping, this.nodeBody_left.getComponent(cc.RigidBody).linearVelocity = this._carBodyData.linearVelocity) : (this.nodeBody_right.getComponent(cc.RigidBody).angularDamping = this._carBodyData.angularDamping, this.nodeBody_right.getComponent(cc.RigidBody).angularVelocity = -this._carBodyData.angularVelocity, this.nodeBody_right.getComponent(cc.RigidBody).linearDamping = this._carBodyData.linearDamping, this.nodeBody_right.getComponent(cc.RigidBody).linearVelocity = this._carBodyData.linearVelocity)
    },
    e.prototype.onMoveLinear = function() {},
    e.prototype.onMoveCancel = function() {
        this.wheel0Control && this.wheel0Control.onMoveCancel(),
        this.wheel1Control && this.wheel1Control.onMoveCancel(),
        this.setCurMoveOrient(r.Car_Orientation.Default)
    },
    e.prototype.onAirShipIn = function(t) {
        switch (this.wheel0Control && this.wheel0Control.onAirShipIn(), this.wheel1Control && this.wheel1Control.onAirShipIn(), t) {
            case r.Physics_Car_Tag.Left:
                this.nodeBody_left.active = !1,
            this.node.active = !1;
            break;
            case r.Physics_Car_Tag.Right:
                this.nodeBody_right.active = !1,
            this.node.active = !1;
        }
    },
    e.prototype.onAirShipOut = function(t, e) {
        this.wheel0Control && this.wheel0Control.onAirShipOut(),
        this.wheel1Control && this.wheel1Control.onAirShipOut();
        var o = function(t, e) {
            u.default.nCurGameType == r.Game_Type.PK ? t.position = cc.v3(e.x, e.y + r.Game_PK_Car_PosY, e.z) : u.default.nCurGameType == r.Game_Type.PK_1 ? t.position = cc.v3(e.x, e.y + r.Game_PK_Car_PosY, e.z) : u.default.nCurGameType == r.Game_Type.PK_2 ? t.position = cc.v3(e.x, e.y, e.z) : t.position = e
        };
        switch (t) {
            case r.Physics_Car_Tag.Left:
                this.nodeBody_left.angle = 0,
            o(this.nodeBody_left, e),
            this.nodeBody_left.active = !0,
            this.node.active = !0;
            break;
            case r.Physics_Car_Tag.Right:
                this.nodeBody_right.angle = 0,
            o(this.nodeBody_right, e),
            this.nodeBody_right.active = !0,
            this.node.active = !0;
        }
    },
    e.prototype.onRollingOver = function(t) {
        if (this.nCurOrient != t) {
            this.setCarCurOrient(t);
            var e = 0,
            o = 0;
            this.wheel0Control && (e = this.wheel0Control.getRadius()),
            this.wheel1Control && (o = this.wheel1Control.getRadius());
            var i = 0;
            0 == e && 0 != o ? i = 2 * o: 0 != e && 0 == o && (i = 2 * -e);
            var n = Math.abs(i) / 2;
            if (this._carTag == r.Physics_Car_Tag.Left) {
                if (t == r.Car_Orientation.Right) {
                    if (0 != i) {
                        this.nodeBody_left.active = !1;
                        var a = this.nodeBody_left.position;
                        this.nodeBody_left.position = cc.v3(a.x - i, a.y + n, a.z),
                        this.nodeBody_left.active = !0
                    }
                    this.nodeBody_left.scaleX = Math.abs(this.nodeBody_left.scaleX)
                } else 0 != i && (this.nodeBody_left.active = !1, a = this.nodeBody_left.position, this.nodeBody_left.position = cc.v3(a.x + i, a.y + n, a.z), this.nodeBody_left.active = !0),
                this.nodeBody_left.scaleX = -Math.abs(this.nodeBody_left.scaleX);
            } else this._carTag == r.Physics_Car_Tag.Right && (t == r.Car_Orientation.Left ? (0 != i && (this.nodeBody_right.active = !1, a = this.nodeBody_right.position, this.nodeBody_right.position = cc.v3(a.x + i, a.y, a.z), this.nodeBody_right.active = !0), this.nodeBody_right.scaleX = Math.abs(this.nodeBody_right.scaleX)) : (0 != i && (this.nodeBody_right.active = !1, a = this.nodeBody_right.position, this.nodeBody_right.position = cc.v3(a.x - i, a.y, a.z), this.nodeBody_right.active = !0), this.nodeBody_right.scaleX = -Math.abs(this.nodeBody_right.scaleX)))
        }
    },
    e.prototype.onAIMove = function(t, e) {
        var o = this;
        if (this.bAIStart) {
            if (this.nCurAIMoveTime += t, this.bPreAiMoveTime += t, !(this.bPreAiMoveTime < this.intervalTime)) {
                this.intervalTime = .1,
                this.bPreAiMoveTime = 0;
                var i = p.Util.getRandomInt(2, 4) / 10,
                n = function(t) {
                    o.nCurMoveOrient == r.Car_Orientation.Left ? o.nCurAIMoveTime > i ? (o._gameControl.onMoveCancel(r.Collide_Car_Tag.Right, !0), o.nCurAIMoveTime = 0) : t ? o._gameControl.onMoveLeft(r.Collide_Car_Tag.Right, !0) : o.nCurAIMoveTime > 0 && o.nCurAIMoveTime < 4 * i ? o._gameControl.onMoveCancel(r.Collide_Car_Tag.Right, !0) : o._gameControl.onMoveLeft(r.Collide_Car_Tag.Right, !0) : (o._gameControl.onMoveLeft(r.Collide_Car_Tag.Right, !0), o.nCurAIMoveTime = 0)
                },
                a = function(t) {
                    o.nCurMoveOrient == r.Car_Orientation.Right ? o.nCurAIMoveTime > i ? (o._gameControl.onMoveCancel(r.Collide_Car_Tag.Right, !0), o.nCurAIMoveTime = 0) : t ? o._gameControl.onMoveRight(r.Collide_Car_Tag.Right, !0) : o.nCurAIMoveTime > 0 && o.nCurAIMoveTime < 4 * i ? o._gameControl.onMoveCancel(r.Collide_Car_Tag.Right, !0) : o._gameControl.onMoveRight(r.Collide_Car_Tag.Right, !0) : (o._gameControl.onMoveRight(r.Collide_Car_Tag.Right, !0), o.nCurAIMoveTime = 0)
                };
                if ((e %= 360) < 0 && (e += 360), e > 60 && e < 120) n(!0),
                this.intervalTime = 1;
                else if (e < 300 && e > 240) a(!0),
                this.intervalTime = 1;
                else if (e >= 0 && e < 60 || e <= 360 && e > 300) {
                    var s = this._gameControl._carLeftView.getCarWorldPos(),
                    l = this._gameControl._carRightView.getCarWorldPos(),
                    c = this._gameControl._carLeftView.getCarBodyWidth(),
                    d = this._gameControl._carRightView.getCarBodyWidth();
                    l.x > s.x ? l.x - s.x < (c + d) / 2 && Math.abs(l.y - s.y) > 50 ? this._gameControl._carRightView.getCurOrient() == r.Car_Orientation.Left ? this._gameControl.onMoveLeft(r.Collide_Car_Tag.Right, !0) : this._gameControl.onMoveRight(r.Collide_Car_Tag.Right, !0) : l.x - s.x > (c + d) / 2 && l.x - s.x < (c + d) / 2 + 200 && this.nCurMoveOrient == r.Car_Orientation.Left ? (this._gameControl.onMoveCancel(r.Collide_Car_Tag.Right, !0), this.nCurAIMoveTime = 0) : n(!1) : l.x - s.x > -(c + d) / 2 && Math.abs(l.y - s.y) > 50 ? this._gameControl._carRightView.getCurOrient() == r.Car_Orientation.Left ? this._gameControl.onMoveLeft(r.Collide_Car_Tag.Right, !0) : this._gameControl.onMoveRight(r.Collide_Car_Tag.Right, !0) : l.x - s.x < -(c + d) / 2 && l.x - s.x > -(c + d) / 2 - 200 && this.nCurMoveOrient == r.Car_Orientation.Right ? (this._gameControl.onMoveCancel(r.Collide_Car_Tag.Right, !0), this.nCurAIMoveTime = 0) : a(!1)
                } else e >= 120 && e <= 180 ? (a(!0), this.intervalTime = 1) : e > 180 && e <= 240 && (n(!0), this.intervalTime = 1)
            }
        } else {
            this.nCurAIMoveTime += t;
            var h = r.GameStart_Time_interval + p.Util.getRandomInt(3, 8) / 10;
            this.nCurAIMoveTime > h && (this.nCurAIMoveTime = 0, this.bAIStart = !0)
        }
    },
    a([y(cc.Prefab)], e.prototype, "pfb_role", void 0),
    a([y(cc.Prefab)], e.prototype, "pfb_wheel", void 0),
    a([y(cc.Prefab)], e.prototype, "pfb_wheelAlone", void 0),
    a([y(cc.Node)], e.prototype, "nodeBody_left", void 0),
    a([y(cc.Node)], e.prototype, "nodeBody_right", void 0),
    a([_], e)
} (cc.Component);
o.default = g